package cn.net.shuxing.yifu.common.back.controller;

import cn.net.shuxing.yifu.common.bean.BaseArea;
import cn.net.shuxing.yifu.common.dto.BaseDto;
import cn.net.shuxing.yifu.common.service.BaseAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/area")
public class BaseAreaController {

    @Autowired
    BaseAreaService baseAreaService;


    /**
     * 获取省列表
     * @return
     */
    @RequestMapping("/province")
    public BaseDto getProvinceList(){
        BaseDto baseDto = new BaseDto();
        List<BaseArea> baseAreaList = baseAreaService.getProvinceList();
        baseDto.setData(baseAreaList);
        return baseDto;
    }

    /**
     * 获取市列表
     * @param provinceId
     * @return
     */
    @RequestMapping("/city")
    public BaseDto getCityList(Integer provinceId){
        BaseDto baseDto = new BaseDto();
        List<BaseArea> baseAreaList = baseAreaService.getCityList(provinceId);
        baseDto.setData(baseAreaList);
        return baseDto;
    }

    /**
     * 获取区/县列表
     * @param cityId
     * @return
     */
    @RequestMapping("/district")
    public BaseDto getDistrictList(Integer cityId){
        BaseDto baseDto = new BaseDto();
        List<BaseArea> baseAreaList = baseAreaService.getDistrictList(cityId);
        baseDto.setData(baseAreaList);
        return baseDto;
    }


}
